//
//  XOWMView.m
//  XOWMSDK
//
//  Created by skyline on 2018/7/25.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "XOWMView.h"
CGFloat const TITLE_HEIGHT = 30;
CGFloat const LINE_HEIGHT = 0.8;
CGFloat const SELECTSERBTN_HEIGHT = 15;
CGFloat const BACKBUTTON_HEIGHT = TITLE_HEIGHT;
@interface XOWMView()
@property (nonatomic, strong) XOWMImageView *imageView;
@property (nonatomic, strong) UIView *line;
@end
@implementation XOWMView
- (instancetype)init
{
    self = [super init];
    if (self)
    {
        self.layer.masksToBounds = YES;
        self.bounds = CGRectMake(0, 0, SCREEN_MIN_LENGTH - 2 * GAP,  TEXTFILDHEIGHT * 5 + GAP * 3);
        self.imageView.hidden = (helperManager().getPara().style == XOWMPlatformStyleImage)?NO:YES;
        self.line.hidden = (helperManager().getPara().style == XOWMPlatformStyleImage)?YES:NO;
        self.backBtn.content = (helperManager().getPara().style == XOWMPlatformStyleImage)?@"yjd_返回_Btn":@"back";
        self.backgroundColor = (helperManager().getPara().style == XOWMPlatformStyleImage)?[UIColor clearColor]:RGBA(230, 230, 230, 0.7);
        self.layer.cornerRadius = (helperManager().getPara().style == XOWMPlatformStyleImage)?0.0:5.0;
    }
    return self;
}

- (XOWMButton *)backBtn
{
    if (!_backBtn)
    {
        _backBtn = [[XOWMButton alloc] init];
        _backBtn.height = BACKBUTTON_HEIGHT;
        _backBtn.style = YJDButtonTitleStyleCameo;
        [_backBtn addTarget:self action:@selector(yjd_actionForBackButton) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_backBtn];
        _backBtn.c_left.equal(self).with.coffset(0);
        if (helperManager().getPara().style == XOWMPlatformStyleImage)
        _backBtn.c_top.equal(self).with.coffset(GAP);
        else
            _backBtn.c_top.equal(self).with.coffset(GAP / 2.0);
    }
    return _backBtn;
}

- (XOWMImageView *)imageView
{
    if (!_imageView)
    {
        _imageView = [[XOWMImageView alloc] init];
        _imageView.imageName = @"yjd_背景";
        [self addSubview:_imageView];
        _imageView.c_edges.equal(UIEdgeInsetsZero);
    }
    return _imageView;
}

- (UIView *)line
{
    if (!_line)
    {
        _line = [[UIView alloc] init];
        _line.backgroundColor = RGBA(208, 208, 210, 1.0);
        [self addSubview:_line];
        _line.c_top.equal(self).with.coffset(TITLE_HEIGHT + GAP);
        _line.c_left.equal(self);
        _line.c_right.equal(self);
        _line.c_height.equal(LINE_HEIGHT);
    }
    return _line;
}


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */


- (void)sp_didUserInfoFailed {
    NSLog(@"Check your Network");
}
@end
